<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--标准mui.css-->
	<link rel="stylesheet" href="./css/mui.min.css">
	<!--App自定义的css-->
	<link rel="stylesheet" type="text/css" href="./css/main.css" />
    <title>注册公司 </title>
    <style>

    </style>
</head>
<body>
    <div class="wrap">
        <div class="deleDetail" style="display:block">
            <div class="deleInfo">
                <div class="left"><span class="red">*</span>所在地区</div>
                <div class="right" id="area"><input type="text" value='' placeholder="请选择所在地区" readonly class="number" id="city"><img src="./images/right.png" alt="" class="icon-right"></div>
            </div>
            <div class="deleInfo">
                <div class="left"><span class="red">*</span>所属行业</div>
                <div class="right" id="entrust"><input type="text" value='' placeholder="请选择所属行业" readonly class="number" id="industry"><img src="./images/right.png" alt="" class="icon-right"></div>
            </div>
            <div class="deleInfo">
                <div class="left"><span class="red">*</span>公司名称</div>
                <div class="right"><input type="text" value='' class="number" id="company"></div>
            </div>
            <div class="deleInfo">
                <div class="left"><span class="red">*</span>联系人</div>
                <div class="right"><input type="text" value='' class="number" id="contacter"></div>
            </div>
            <div class="deleInfo">
                <div class="left"><span class="red">*</span>联系电话</div>
                <div class="right"><input type="text" value='' class="number" id="contactphone" maxlength="11"></div>
            </div>
            <!-- <div class="deleInfo">
                <div class="left"><span class="red">*</span>联系地址</div>
                <div class="right"><textarea name="name" class="account_area" id="registeraddress"></textarea></div>
            </div> -->

        </div>
    </div>
    <footer class="footer">
        提交申请
    </footer>
    <!-- 第一层 -->
    <div class="big">
        <div class="anit_rigth">

        </div>
    </div>
    <script src="./js/mui.min.js"></script>
	<script src="./js/jquery-3.2.1.min.js" charset="utf-8"></script>
    <script src="./js/path.js" charset="utf-8"></script>
    <script type="text/javascript">
        $("#area").click(function(){
            window.location.href="./city.html?id="+2;
        })
        var city = decodeURI(getQueryString('city'));
        if(city){
            $("#city").val(city);
        }
        // 点击选择行业
        $(document).on('touchstart','#industry',()=>{
            var city = $("#city").val();
            if(!city){
                mui.alert('请先选择地区！');
                return;
            }
            $(".big").show();
            $(".anit_rigth").animate({
                left: '20%'
            });
            $(".anit_rigth").empty();
            $.ajax({
                url:path + '/comm/industry/list',
                dataType:'json',
                type:'post',
                data:{
                   pid:0
                },
                success:(data)=>{
                    console.log(data);
                    var html='';
                    html+='<div class="nameways">公司<span id="back_t">返回</span></div>';
                    html+='<div class="mui-input-row mui-search">';
                    html+='<input type="search" class="mui-input-clear industy" placeholder="请输入关键字，例如：销售">';
                    html+='</div>';
                    html+='<div class="industryList">';
                    html+='<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                    for (var i = 0; i < data.data.length; i++) {
                        if(data.data[i].childCount>0){
                            html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                            html+='<p class="industrylist_name">'+data.data[i].spmc+'<img src="./images/right.png" alt="" class="icon-right"/></p>';
                        }else{
                            html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                            html+='<p class="industrylist_name">'+data.data[i].spmc+'</p>';
                        }
                    }
                    html+='</div>';
                    $('.anit_rigth').empty();
                    $('.anit_rigth').append(html);
                    $('.big').show();
                    $('.anit_rigth').show();
                },
                error:(err)=>{
                    mui.alert(err.message)
                }
            })
        })
        // 点击选择行业的下级
        $(document).on('touchstart','.industrylist_name',function(){
            var spbm = $(this).prev().val();
            var spmc = $(this).text();
            $.ajax({
                url:path+'/comm/industry/list',
                dataType:'json',
                type:'post',
                data:{
                    pid : spbm
                },
                success:(data)=>{
                    console.log(data);
                    if(data.data.length==0){
                        $("#industry").val(spmc);
                        $('.big').hide();
                        $('.anit_rigth').hide();
                        $('.anit_rigth').empty();
                    }else{
                        var html='';
                        html+='<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                        for (var i = 0; i < data.data.length; i++) {
                            if(data.data[i].childCount>0){
                                html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                                html+='<p class="industrylist_name">'+data.data[i].spmc+'<img src="./images/right.png" alt="" class="icon-right"/></p>';
                            }else{
                                html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                                html+='<p class="industrylist_name">'+data.data[i].spmc+'</p>';
                            }
                        }
                        $(".industryList").empty();
                        $(".industryList").append(html);
                    }
                },
                error:(err)=>{
                    mui.alert(err.message);
                }
            })
        })
        // 行业列表点击返回按钮返回第一级
        $(document).on('touchstart','.industrylist_back',function(){
            $.ajax({
                url:path + '/comm/industry/list',
                dataType:'json',
                type:'post',
                data:{
                   pid:0
                },
                success:(data)=>{
                    $('.anit_rigth').empty();
                    var html='';
                    html+='<div class="nameways">公司<span id="back_t">返回</span></div>';
                    html+='<div class="mui-input-row mui-search">';
                    html+='<input type="search" class="mui-input-clear industy" placeholder="请输入关键字，例如：销售">';
                    html+='</div>';
                    html+='<div class="industryList">';
                    html+='<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                    for (var i = 0; i < data.data.length; i++) {
                        if(data.data[i].childCount>0){
                            html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                            html+='<p class="industrylist_name">'+data.data[i].spmc+'<img src="./images/right.png" alt="" class="icon-right"/></p>';
                        }else{
                            html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                            html+='<p class="industrylist_name">'+data.data[i].spmc+'</p>';
                        }
                    }
                    html+='</div>';
                    $('.anit_rigth').append(html);
                },
                error:(err)=>{
                    mui.alert(err.message)
                }
            })
        })
        //点击返回
        $(document).on('touchstart', '#back_t', () => {
            $(".anit_rigth").animate({
                left: '100%'
            },500,()=>{
                $('.anit_rigth').empty();
                $('.big').hide();
                $('.anit_rigth').hide();
            });
        })
        // 提交
        $(".footer").click(()=>{
            var company = $("#company").val();
            var contacter = $("#contacter").val();
            var contactphone = $("#contactphone").val();
            var city = $("#city").val();
            var industry = $("#industry").val();
            // var registeraddress = $('#registeraddress').val();
            $.ajax({
                url:path + '/app/registerCompany/submit',
                dataType:'json',
                type:'post',
                data:{
                    company : company,
                    contacter :　contacter,
                    contactphone : contactphone,
                    city : city,
                    industryname : industry,
                    // reporttaxtype : reporttaxtype
                },
                success:(data)=>{
                    if(data.success==1){
                        mui.alert(data.message,function(){
                            window.location.href='./index.html';
                        })
                    }
                },
                error:(err)=>{
                    mui.alert(err.message);
                }
            })
        })
        // 行业查询
        $(document).on('keypress','.industy',function(e){
            var spmc = $(this).val();
            var keycode = e.keyCode;
            if(keycode=='13') {
                e.preventDefault();
                $.ajax({
                    url:path+'/comm/industry/list',
                    dataType:'json',
                    type:'post',
                    data:{
                        spmc : spmc
                    },
                    success:(data)=>{
                        console.log(data);
                        var html = '';
                        $('.industryList').empty();
                        if(data.data.length>0){
                            for (var i = 0; i < data.data.length; i++) {
                                if(data.data[i].childCount>0){
                                    html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                                    html+='<p class="industrylist_name">'+data.data[i].spmc+'<img src="./images/right.png" alt="" class="icon-right"/></p>';
                                }else{
                                    html+='<input type="hidden" value="'+data.data[i].spbm+'"/>'
                                    html+='<p class="industrylist_name">'+data.data[i].spmc+'</p>';
                                }
                            }
                        }else{
                            html+='<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                            html+='<p class="result_note">暂无行业信息！</p>';
                        }
                        $('.industryList').append(html);
                    },
                    error:(err)=>{
                        mui.alert(err.message);
                    }
                })
            }
        })
    </script>
</body>
</html>
